package com.eningqu.aipen.logic.network;

import com.eningqu.aipen.logic.model.ResponseBean;
import com.eningqu.aipen.logic.model.chat.ChatResponseBean;
import com.eningqu.aipen.logic.model.chat.ChatTokenBean;
import com.eningqu.aipen.logic.model.login.LoginResponseBean;
import com.eningqu.aipen.logic.model.login.LoginUserBean;
import com.eningqu.aipen.logic.model.medical.GhSingleBean;
import com.eningqu.aipen.logic.model.medical.GhTodayBean;
import com.eningqu.aipen.logic.model.medical.MedicalBean;
import com.eningqu.aipen.logic.model.medical.MedicalBookBean;
import com.eningqu.aipen.logic.model.medical.MedicalBookSingleBean;
import com.eningqu.aipen.logic.model.medical.MedicalNode;
import com.eningqu.aipen.logic.model.medical.MedicalNodeBean;
import com.eningqu.aipen.logic.model.medical.MedicalNodeWithXyModelBean;
import com.eningqu.aipen.logic.model.medical.MedicalNodeWithZyModelBean;
import com.eningqu.aipen.logic.model.medical.PatientBean;
import com.eningqu.aipen.logic.model.mine.DoctorBean;
import com.eningqu.aipen.logic.model.write.WriteResponseBean;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface Apis {


    /**
     * 文心一言APi
     */

    @Headers({
            "Accept:application/json",
            "Content-Type:application/json"
    })
    @POST("oauth/2.0/token")
    Observable<ChatTokenBean> getBaiduToken(
            @Query("client_id") String clientId,
            @Query("client_secret") String clientSecret,
            @Query("grant_type") String client_credentials);


    @Headers({
            "Accept:application/json",
            "Content-Type:application/json"
    })
    @POST("/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant")
    Observable<ChatResponseBean> startChat(
            @Body RequestBody param,
            @Query("access_token") String accessToken
    );

    /**
     * 手写识别api
     */

    //url("https://aip.baidubce.com/rest/2.0/ocr/v1/handwriting?access_token=" + getAccessToken())
    @Headers({
            "Accept:application/json",
            "Content-Type: application/x-www-form-urlencoded"
    })
    @POST("rest/2.0/ocr/v1/handwriting")
    Observable<WriteResponseBean> getWriteResult(
            @Body RequestBody param,
            @Query("access_token") String accessToken
    );

    /**
     * 医生登录
     */
    @POST("app/emr_login")
    Observable<LoginResponseBean> login(@Body LoginUserBean param);

    /**
     * 医生注册
     */
    @Headers({
            "Accept:application/json",
            "Content-Type:application/json"
    })
    @POST("app/emr_register")
    Observable<LoginResponseBean> register(@Body LoginUserBean param);


    /**
     * 根据患者的病历编号寻找所有的西医病历信息节点
     */
//    http://localhost:8080/renren-fast/hospital/jd/medical_node?blId=1
    @GET("hospital/emrjdinfo/getXyJdByBlId")
    Observable<MedicalNodeWithXyModelBean> getMedicalXyNodeById(@Query("blId") Integer blId);


    //hospital/emrjdinfo/getZyJdByBlId?blId=4
    @GET("hospital/emrjdinfo/getZyJdByBlId")
    Observable<MedicalNodeWithZyModelBean> getMedicalZyNodeById(@Query("blId") Integer blId);

    /**
     * 保存病历节点
     */
    //http://localhost:8080/renren-fast/hospital/jd/save
    @POST("hospital/emrjdinfo/save")
    Observable<ResponseBean> saveMedicalNode(@Body MedicalNode body);


    /**
     * 获取医生个人信息
     */
    //http://localhost:8080/renren-fast/hospital/emrysinfo/info/8
    @GET("hospital/emrysinfo/info/{emrYsId}")
    Observable<DoctorBean> getDoctorInfo(@Path("emrYsId") Integer ysId);

    /**
     * 获取患者个人信息
     */
    @GET("hospital/emrhzinfo/info/{emrHzId}")
    Observable<PatientBean> getHzInfo(@Path("emrHzId") Integer hzId);


    /**
     * 获取今日挂号记录
     */
    @GET("hospital/emrghinfo/getGhListByYsId")
    Observable<GhTodayBean> getTodayGh(@Query("ysId") Integer ysId);


    /**
     * 获取所有的病历本
     */
    @GET("hospital/emrblinfo/list")
    Observable<MedicalBookBean> findAllMedicalBook(@Query("params") Integer params);


    /**
     * 根据患者id获取病历信息
     */
    @POST("hospital/emrblinfo/getBlByHzId")
    Observable<MedicalBookSingleBean> getBlByHzId(@Query("hzId") Integer hzId);

    /**
     * 更新病历信息
     */
    //http://8.130.124.187:8080/renren-fast/hospital/bl/update
    @POST("hospital/bl/update")
    Call<ResponseBean> updateMedical(@Body MedicalBean.BlDTO medicalBean);

    /**
     * 更新病历信息
     */
    //http://8.130.124.187:8080/renren-fast/hospital/bl/update
    @POST("hospital/bl/update")
    Observable<ResponseBean> updateMedicalRx(@Body MedicalBean.BlDTO medicalBean);

    /**
     * 通过id获取病历
     */
    //http://8.130.124.187:8080/renren-fast/hospital/bl/info/1
    @GET("hospital/bl/info/{blId}")
    Call<MedicalBean> getMedicalById(@Path("blId") Integer blId);

    /**
     * 通过id获取病历
     */
    //http://8.130.124.187:8080/renren-fast/hospital/bl/info/1
    @GET("hospital/bl/info/{blId}")
    Observable<MedicalBean> getMedicalByIdRx(@Path("blId") Integer blId);

    /**
     * 保存病历节点
     */
    //http://8.130.124.187:8080/renren-fast/hospital/jd/update
    @POST("hospital/jd/update")
    Call<ResponseBean> updateMedicalNode(@Body MedicalNodeBean.PageDTO bean);

    /**
     * rx保存病历节点
     */
    //http://8.130.124.187:8080/renren-fast/hospital/jd/update
    @POST("hospital/jd/update")
    Observable<ResponseBean> updateMedicalNodeRx(@Body MedicalNodeBean.PageDTO bean);

    /**
     * 单文件上传
     */
    //
    @Multipart
    @POST("hospital/jd/saveWithImg")
    Call<ResponseBean> uploadSingleFile(@Part MultipartBody.Part file);

    /**
     * rxJava单文件上传 上传至自己的服务器
     */
    //
    @Multipart
    @POST("hospital/jd/saveWithImg")
    Observable<ResponseBean> uploadSingleFileRx(@Part MultipartBody.Part file);

    /**
     * 多文件上传 上传至自己的服务器
     */

    //POST /hospital/jd/saveImgs
    @Multipart
    @POST("hospital/jd/saveImgs")
    Call<ResponseBean> uploadMultiFiles(@Part List<MultipartBody.Part> files);

    //Post
    @Multipart
    @POST("hospital/img/uploadAliyun")
    Observable<ResponseBean> uploadAliyun(@Part MultipartBody.Part file);

    /**
     * 上传至阿里云图床
     */
    @Multipart
    @POST("hospital/img/uploagAliyunImgs")
    Observable<ResponseBean> uploagAliyunImgs(@Part List<MultipartBody.Part> files);

    /**
     * rxJava多文件上传
     */
    @Multipart
    @POST("hospital/jd/saveImgs")
    Observable<ResponseBean> uploadMultiFilesRx(@Part List<MultipartBody.Part> files);


    /**
     * 获取挂号信息
     */
    @GET("hospital/emrghinfo/info/{emrGhId}")
    Observable<GhSingleBean> getGhInfo(@Path("emrGhId") Integer ghId);

    /**
     * 更新挂号信息
     */
    @POST("hospital/emrghinfo/update")
    Observable<ResponseBean> updateGhInfo(@Body GhSingleBean.EmrGhInfoDTO ghInfoDTO);


    /**
     * 更新病历信息
     */
    //?blId=3&time=2024-02-19%2004%3A51%3A50
    @POST("hospital/emrblinfo/updateTime")
    Observable<ResponseBean> updateTime(@Query("blId") Integer blId, @Query("time") String time);

}

